import _ from 'lodash';
import { antdItem } from '../itemStore';
import { EnumMetadataType } from '../configs/dictionaries';
export function createMenuItem(fieldList) {
  var chooseComponent = function (item) {
    if (item.dict_type_id) {
      return 'select';
    } else {
      switch (item.field_type) {
        case EnumMetadataType.Int:
          return 'inputNumber';
        case EnumMetadataType.Long:
          return 'inputNumber';
        case EnumMetadataType.Float:
          return 'inputNumber';
        case EnumMetadataType.Date:
          return 'datePicker';
        case EnumMetadataType.Time:
          return 'datePicker';
        default:
          return 'input';
      }
    }
  };
  var newList = fieldList.map(function (field) {
    var type = _.cloneDeep(antdItem[chooseComponent(field)]);
    type.formType = type.type;
    type.configs.itemProps.name = field.field_name;
    (type.configs.itemProps.label = field.field_desc), (type.type = field.field_name);
    return {
      key: field.field_name,
      value: type
    };
  });
  console.log('newList', newList);
  return newList.reduce(function (pre, cur) {
    pre[cur.key] = cur.value;
    return pre;
  }, {});
}
